const router = require("koa-router")();
const UserModel = require("../../models/user");
router.post("/api/login",async ctx=>{
    // console.log(ctx.request.body);
    let {username,password} = ctx.request.body;
    var res = await UserModel.find({name:username,password});
    if(res.length!=0){
        ctx.body = {
            code:200,
            res,
            msg:`登录成功!`
        }
    }else{
        ctx.body = {
            code:400,
            msg:"账号或者密码错误！"
        }
    }
    console.log(res);
})
module.exports = router;